package com.yvon.maple.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author : Yvon
 * @since : 2021-09-24
 */
public enum GenderEnum {
    /**
     * 男.
     */
    male(1, "男"),

    /**
     * 女.
     */
    female(2, "女"),


    /*
     * 保密.
     */
    secrecy(3, "保密");


    /**
     * Code
     */
    @EnumValue
    private final Integer code;

    /**
     * Name
     */
    private final String message;


    /**
     * Message category.
     *
     * @param code the code
     * @param message the name
     */
    GenderEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }



    /**
     * Get code string.
     *
     * @return {@link String }
     * @author : Yvon / 2021-08-26
     */
    @JsonValue
    public Integer getCode() {
        return code;
    }

    /**
     * Get message string.
     *
     * @return {@link String }
     * @author : Yvon / 2021-08-26
     */
    public String getMessage() {
        return message;
    }

    public static GenderEnum getByCode(Integer code){
        for (GenderEnum p : GenderEnum.values()) {
            if (code.equals(p.getCode())){
                return p;
            }
        }
        return null;
    }
}
